import { useState } from "react";
import styles from "../happle/PosterSection.module.css";

// 导入图片
import img1 from "../props/images/coss1.jpg";
import img2 from "../props/images/coss2.jpg";
import img3 from "../props/images/coss3.jpg";
import img4 from "../props/images/coss4.jpg";
import img5 from "../props/images/coss5.jpg";
import img6 from "../props/images/coss6.jpg";
import img7 from "../props/images/coss7.jpg";
import img8 from "../props/images/coss8.jpg";

// 数据类型定义
interface Festival {
  id: string;
  name: string;
  isHot: boolean;
  templates: Template[];
}

interface Template {
  type: string;
  count: number;
  imageUrl: string;
}

// 模拟数据
const festivals: Festival[] = [
  {
    id: "dragon",
    name: "精选推荐",
    isHot: true,
    templates: [
      {
        type: "春季人像",
        count: 38,
        imageUrl: img1,
      },
      {
        type: "毕业人像",
        count: 47,
        imageUrl: img2,
      },
      {
        type: "汉装古装",
        count: 150,
        imageUrl: img3,
      },
      {
        type: "母婴摄影",
        count: 38,
        imageUrl: img4,
      },
      {
        type: "户外游玩",
        count: 39,
        imageUrl: img5,
      },
      {
        type: "浪漫情侣",
        count: 60,
        imageUrl: img6,
      },
      {
        type: "休闲居家少女",
        count: 88,
        imageUrl: img7,
      },
      {
        type: "商务团队",
        count: 49,
        imageUrl: img8,
      },
    ],
  },
  {
    id: "children",
    name: "职业形象",
    isHot: true,
    templates: [
      {
        type: "职场白领摄影",
        count: 123,
        imageUrl: img3,
      },
      {
        type: "蓝领工人",
        count: 99,
        imageUrl: img4,
      },
      {
        type: "亚洲医生",
        count: 30,
        imageUrl: img5,
      },
      {
        type: "空乘飞行人员",
        count: 60,
        imageUrl: img6,
      },
      {
        type: "家政服务",
        count: 45,
        imageUrl: img1,
      },
      {
        type: "教师学生摄影",
        count: 138,
        imageUrl: img7,
      },
      {
        type: "客服职业人员",
        count: 60,
        imageUrl: img2,
      },
      {
        type: "健身人像摄影",
        count: 97,
        imageUrl: img8,
      },
    ],
  },
  {
    id: "summer",
    name: "东方人像",
    isHot: false,
    templates: [
      {
        type: "亚洲家庭",
        count: 78,
        imageUrl: img2,
      },
      {
        type: "青年人像摄影",
        count: 31,
        imageUrl: img3,
      },
      {
        type: "可爱婴儿",
        count: 87,
        imageUrl: img4,
      },
      {
        type: "儿童人像摄影",
        count: 100,
        imageUrl: img5,
      },
      {
        type: "亚洲老人",
        count: 133,
        imageUrl: img7,
      },
       {
        type: "民族服装",
        count: 162,
        imageUrl: img8,
      },
       {
        type: "旗袍美人",
        count: 81,
        imageUrl: img6,
      },
       {
        type: "潮流写真",
        count: 133,
        imageUrl: img1,
      },
    ],
  },
  {
    id: "grain",
    name: "医疗健康",
    isHot: false,
    templates: [
      {
        type: "专业医护人员",
        count: 182,
        imageUrl: img4,
      },
      {
        type: "儿童医疗",
        count: 183,
        imageUrl: img5,
      },
      {
        type: "营养保健",
        count: 260,
        imageUrl: img7,
      },
      {
        type: "医美护肤",
        count: 113,
        imageUrl: img8,
      },
      {
        type: "生理疼痛",
        count: 106,
        imageUrl: img1,
      },
      {
        type: "时尚妆容",
        count: 67,
        imageUrl: img2,
      },
      {
        type: "美发",
        count: 70,
        imageUrl: img3,
      },
      {
        type: "美甲美睫",
        count: 220,
        imageUrl: img6,
      },
    ],
  }
];
export default function MarketingCalendar() {
  const [selectedFestival, setSelectedFestival] = useState<Festival>(
    festivals[0]
  );
  const [lockSelection, setLockSelection] = useState(false);

  const handleHover = (festival: Festival) => {
    if (!lockSelection) {
      setSelectedFestival(festival);
    }
  };
  const handleClick = (festival: Festival) => {
    setSelectedFestival(festival);
    setLockSelection(true);
  };

  return (
    <div className={styles.container}>
      <div className={styles.headerRow}>
        <h2 className={styles.sectionTitle}>行业趋势-人像篇</h2>
        <p className={styles.sectionDesc}>精选热点专题实时更新,热门素材轻松get~</p>
        <div className={styles.festivalList}>
          {festivals.map((festival) => (
            <div
              key={festival.id}
              className={`${styles.festivalItem} ${
                selectedFestival.id === festival.id ? styles.active : ""
              }`}
              onMouseEnter={() => handleHover(festival)}
              onMouseLeave={() => setLockSelection(false)}
              onClick={() => handleClick(festival)}
            >
              <div className={styles.festivalLeft}>
                <span className={styles.festivalName}>{festival.name}</span>
              </div>
            </div>
          ))}
        </div>
      </div>

      <div className={styles.templateGallery}>
        {selectedFestival.templates.map((template) => (
          <div key={template.type} className={styles.templateCard}>
            <div className={styles.templateContent}>
              <div className={styles.templateImageContainer}>
                <img
                  src={template.imageUrl}
                  alt={template.type}
                  className={styles.templateImage}
                />
              </div>
              <div className={styles.templateInfo}>
                <h4>{template.type}</h4>
                <span>共{template.count}个作品</span>
              </div>
            </div>
          </div>
        ))}
      </div>
    </div>
  );
}